package com.sneaker.shower.mapstruct;

import com.sneaker.shower.entity.domain.order.SubOrderDO;
import com.sneaker.shower.entity.dto.SubOrderDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper(componentModel = "spring")
@Component
public interface SubOrderMapStruct {
    SubOrderMapStruct INSTANCE = Mappers.getMapper(SubOrderMapStruct.class);

    @Mappings({
            @Mapping(target = "receiveInfoGuid", source = "receiveGuid"),
            @Mapping(target = "couponGuid", expression = "java(subOrderDTO.getCouponRespDTO()==null?null:Long.parseLong(subOrderDTO.getCouponRespDTO().getGuid()))")
    })
    SubOrderDO dto2DO(SubOrderDTO subOrderDTO);

    @Mapping(target = "receiveGuid", source = "receiveInfoGuid")
    SubOrderDTO do2DTO(SubOrderDO subOrderDO);

    List<SubOrderDTO> doList2DTOList(List<SubOrderDO> subOrderDOList);
}
